//
//  XHF_MenuStyleViewController.m
//  haojia
//
//  Created by 徐宏飞 on 16/4/21.
//  Copyright © 2016年 徐宏飞. All rights reserved.
//

#import "XHF_MenuStyleViewController.h"
#import "XHF_MenuStyleCVC.h"

#import "XHF_StyleViewController.h"

@interface XHF_MenuStyleViewController ()<UICollectionViewDataSource, UICollectionViewDelegate>

@property (weak, nonatomic) IBOutlet UICollectionView *menuStyleVC;

@end

@implementation XHF_MenuStyleViewController

static NSString *menuStyleCVC_id = @"menuStyleCollecitonViewCell";
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.title = @"所有的风格";
    
    
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
    
    //item 比例4:5
    CGSize size = CGSizeMake(185, 315);
    
    //4  4s  5  5s
    if (SCREEN_WIDTH == 320) {
        size = CGSizeMake(144, 230);
    }
    
    //6 6s
    if (SCREEN_WIDTH == 375) {
        size = CGSizeMake(171, 280);
    }
    
    
    
    flowLayout.itemSize = size;
    flowLayout.sectionInset = UIEdgeInsetsMake(20, 15, 20, 15);
    flowLayout.minimumLineSpacing = 12;
    flowLayout.minimumInteritemSpacing = 10;

    
    _menuStyleVC.collectionViewLayout = flowLayout;

    
    
    
    
    [_menuStyleVC registerNib:[UINib nibWithNibName:@"XHF_MenuStyleCVC" bundle:nil] forCellWithReuseIdentifier:menuStyleCVC_id];
}



#pragma mark - collectionViewDelegate

#pragma mark - 行
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return 20;
}

#pragma mark - item
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    XHF_MenuStyleCVC *cell = [collectionView dequeueReusableCellWithReuseIdentifier:menuStyleCVC_id forIndexPath:indexPath];
    
    
    cell.layer.cornerRadius = 8;
    [cell.layer masksToBounds];
    
    
    return cell;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    
    //进入下一页
    self.hidesBottomBarWhenPushed = YES;
    XHF_StyleViewController *styleVC = [XHF_StyleViewController new];
    [self.navigationController pushViewController:styleVC animated:YES];

}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
